package ui;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import draft.FantasyManager;
import draft.Team;

public class TeamPanel extends JPanel{
	
	private static TeamDescription[] tds;
	private static JTabbedPane pane;
	
	public TeamPanel(){
		setLayout(new GridLayout(1,1));
		setBackground(Color.GRAY);
		pane = new JTabbedPane();
		Team[] teams = FantasyManager.league.teams;
		tds = new TeamDescription[teams.length];
		for (int i = 0; i < teams.length; i++){
			Team team = teams[i];
			TeamDescription td = new TeamDescription(team);
			tds[i] = td;
			pane.addTab(team.name + " ", td);
		}
		add(pane);
	}
	
	public void update(Team currentPick){
		for (int i = 0; i < FantasyManager.league.teams.length; i++){
			if (FantasyManager.league.teams[i] == currentPick){
				tds[i].update();
				return;
			}
		}
		
	}
	
	
	public static void setVisibleTeamTab (int team) {
		pane.setSelectedIndex(team);
	}

}
